<?php
/***************************************************************************
 *   Copyright (C) 2007 by Andrea Blankenstijn, David Dieulivol            *
 *   darkan9el@gmail.com, daviddieulivol5@hotmail.com                      *
 *                                                                         *
 *   All rights reserved.                                                  *
 *   This work is released under the terms of the New BSD License.         *
 *   See LICENSE.BSD file for licensing details                            *
 ***************************************************************************/
/* * *
 * $Id: index.php 49 2007-08-27 18:23:57Z DarkAn9el $
 * * */

/**
 * \file index.php
 * \brief Meta-interface utilisateur aux classes
 */

require 'includes/config.inc.php';

if($CONFIG['xdebug'])
	require('includes/xdebug.inc.php');

require 'classes/ugallery/pdoProxy.class.php';
require 'classes/ugallery/photo.class.php';
require 'classes/ugallery/gallery.class.php';
require 'classes/ugallery/adminPhoto.class.php';
require 'classes/ugallery/adminGallery.class.php';

// Connexion à la DB
$odb = new PdoProxy($CONFIG['db']['dsn'], $CONFIG['db']['prefix'], @$CONFIG['db']['user'], @$CONFIG['db']['pass']);

if(isset($_GET['rss']))
{
	include 'includes/rss.php';
	exit();
}

if((!empty($_SERVER['HTTP_ACCEPT']) AND strpos($_SERVER['HTTP_ACCEPT'],'application/xhtml+xml') == true) AND !isset($_GET['html']))
{
  header('Content-Type: application/xhtml+xml; charset=utf8');
  echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
}
else
{
  header('Content-Type: text/html; charset=utf-8');
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
	<title>µGallery - $Id: index.php 49 2007-08-27 18:23:57Z DarkAn9el $</title>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
	<link rel="alternate" type="application/rss+xml" title="Gallery list" href="?rss" />
	<link rel="alternate" type="application/rss+xml" title="Photo list" href="?rss&amp;chan=photo" />
</head>
<body>

	<?php
	if(isset($_GET['addPhoto']))
	{
		include 'includes/addPhotos.php';
	}
	elseif(isset($_GET['addGallery']))
	{
		include 'includes/addGallery.php';
	}
	else
	{
	?>

	<div id="adminLinks">
		<ul>
			<li><a href="?addGallery">Ajouter une galerie</a></li>
			<li><a href="?addPhoto">Ajouter une photo</a></li>
		</ul>
	</div>

	<div id="galleryList">
	<?php 
		include 'includes/listGalleries.php';
	?>
	</div>

	<div id="photo">
	<?php 
		include 'includes/photo.php';
	?>
	</div>

	<div id="thumbnailList">
	<?php 
		include 'includes/gallery.php';
	?>
	</div>

	<?php
	}
	echo '<p>memory usage : ', xdebug_memory_usage()/1024, 'KB<br/>';
	echo 'memory peak : ', xdebug_peak_memory_usage()/1024, 'KB<br/>';
	echo 'execution time : ', xdebug_time_index(), 's</p>';
	?>
</body>
</html>
